export default {
  state: {
    isCollapse: false,
    tabList: [
      {
        path: '/home',
        name: 'home',
        label: '首页',
        icon: 'home'
      }
    ],
    currentMenu: null
  },
  getters: {
  },
  mutations: {
    changeCollapse(state) {
      state.isCollapse = !state.isCollapse
    },
    selectMenu(state, val) {
      //不是首页 当前菜单
        //不在tablist列表中 添加到列表中
      //是首页 currentmenu = null
      if(val.name !== 'home') {
        state.currentMenu = val 
        const result = state.tabList.findIndex(item => item.name === val.name)
        if(result === -1) {
          state.tabList.push(val)
        }
      }else {
        state.currentMenu = null
      }
    },
    closeTag(state, val) {
      // 删除数据源
      const result = state.tabList.findIndex(item => item.name === val.name)
      // 找得到数据, 获取索引值
      state.tabList.splice(result, 1)
    }
  },
  actions: {
  },
}